function GetRequest() {
    //获取url中"?"符后的字串  
    var url = location.search;
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
var obj = GetRequest();
var thisPage = 1;
var totalPage;
var categoryId = obj.categoryid;
// console.log(categoryId);
$.get("http://193.112.55.79:9090/api/getcategorybyid", { "categoryid": categoryId }, function (res) {
    // console.log({arr:res.result});
    var html = template("goodsListTitleTpl", { arr: res.result });
    $('.content_title').html(html);
})
render();

$('.am-pagination-next').on('tap',function(){
    thisPage+=1;
    render();
})
$('.am-pagination-prev').on('tap',function(){
    thisPage-=1;
    render();
})
function render() {
    $.get("http://193.112.55.79:9090/api/getproductlist", { "categoryid": categoryId, "pageid": thisPage }, function (res) {
        // console.log(res.totalCount);
        // console.log(res.pagesize);
        totalPage = Math.ceil(res.totalCount/res.pagesize);
        var html = template("goodsListcontentTpl", { arr: res.result });
        $('#contentList').html(html);
        $('#pageCount').html(thisPage + "/" +totalPage);
    })
}
